From 0a5e9587e01ddfd1ab9c711bda7ccbe985b31018 Mon Sep 17 00:00:00 2001 From: jfatherton Date: Wed, 8 Sep 2004 02:13:22 +0000 Subject: [PATCH] Fixed user defaults for OS X 10.3 --- gpsbabel/macgpsbabel/MacGPSBabel.applescript | 233 ++++++++++++++++-- .../MacGPSBabel.pbproj/jeremya.pbxuser | 115 +++++++-- .../MacGPSBabel.pbproj/project.pbxproj | 62 ++--- 3 files changed, 334 insertions(+), 76 deletions(-) diff --git a/gpsbabel/macgpsbabel/MacGPSBabel.applescript b/gpsbabel/macgpsbabel/MacGPSBabel.applescript index 10ac11e53..74182221c 100644 --- a/gpsbabel/macgpsbabel/MacGPSBabel.applescript +++ b/gpsbabel/macgpsbabel/MacGPSBabel.applescript @@ -1,30 +1,102 @@ -- MacGPSBabel: MacGPSBabel.applescript -- File created by Jeremy Atherton on Sunday, September 28, 2003. --- Last modified by Jeremy Atherton on Thursday, September 2, 2004. +-- Last modified by Jeremy Atherton on Tuesday, September 7, 2004. -- MacGPSBabel is part of the gpsbabel project and is Copyright (c) 2004 Robert Lipe. -- see http://gpsbabel.sourceforge.net/ for more details -- PROPERTIES AND GLOBALS -- property fileList : {} +property startIndex : 0 +property startState : false global theFiles, typeList, extList, aFile -- EVENT HANDLERS -- -- Start up scripts --- get supported file types from gpsbabel and use these to populate the file types popup lists --- on awake from nib theObject --- if theObject is window "MacGPSBabel" then --- tell window "MacGPSBabel" --- set popList to my getFormats() --- repeat with i in popList --- make new menu item at the end of menu items of menu of popup button "inPop" with properties {title:i, enabled:true} --- make new menu item at the end of menu items of menu of popup button "outPop" with properties {title:i, enabled:true} --- end repeat --- end tell --- end if --- end awake from nib + +-- make empty entries in user defaults +on will finish launching theObject + make new default entry at end of default entries of user defaults with properties {name:"theInputType", contents:startIndex} + make new default entry at end of default entries of user defaults with properties {name:"theOutputType", contents:startIndex} + make new default entry at end of default entries of user defaults with properties {name:"gpsIN", contents:startState} + make new default entry at end of default entries of user defaults with properties {name:"gpsOUT", contents:startState} + make new default entry at end of default entries of user defaults with properties {name:"gpsReceiver", contents:startIndex} +end will finish launching + +on awake from nib theObject + if theObject is window "MacGPSBabel" then + + -- get supported file types from gpsbabel and use these to populate the file types popup lists + tell window "MacGPSBabel" + set popList to my getFormats() + repeat with i in popList + make new menu item at the end of menu items of menu of popup button "inPop" with properties {title:i, enabled:true} + make new menu item at the end of menu items of menu of popup button "outPop" with properties {title:i, enabled:true} + end repeat + end tell + + -- read current user defaults and set window controls as needed + my readSettings() + + -- deal with changes to MacGPSBabel window needed if any of the GPS check boxes are checked by default + if state of button "GPSswitchIN" of window "MacGPSBabel" is equal to 1 then + my gpsIN() + end if + if state of button "GPSswitchOUT" of window "MacGPSBabel" is equal to 1 then + my gpsOUT() + end if + end if +end awake from nib + +-- Deal with the opening and closing of windows + +on will open theObject + + -- Main Window + if theObject is window "MacGPSBabel" then + -- set the progress indicator style + set p to progress indicator 1 of theObject + call method "setStyle:" of p with parameter 1 + call method "setDisplayedWhenStopped:" of p with parameters {false} + end if + + -- Select GPS Window + if theObject is window "SelectGPS" then + -- get the list of available serial ports + set popList to my getSerial() + -- use popList to populate the drop-down menu + delete every menu item of menu of popup button "serialPop" of window "SelectGPS" + repeat with i in popList + make new menu item at the end of menu items of menu of popup button "serialPop" of window "SelectGPS" with properties {title:i, enabled:true} + end repeat + + -- read user defaults for this window + tell user defaults + set defaultgpsReceiver to contents of default entry "gpsReceiver" + end tell + set state of popup button "gpsPop" of window "SelectGPS" to defaultgpsReceiver + + -- hide MacGPSBabel window + set visible of window "MacGPSBabel" to false + end if + +end will open + +on will close theObject + if theObject is window "SelectGPS" then + -- store user defaults for this window + set newReceiverIndex to contents of popup button "gpsPop" of window "SelectGPS" as integer + tell user defaults + set contents of default entry "gpsReceiver" to newReceiverIndex + end tell + + -- unhide MacGPSBabel window + set visible of window "MacGPSBabel" to true + end if +end will close + -- handler for the File>Open menu item on choose menu item theObject @@ -56,7 +128,8 @@ on choose menu item theObject end if end choose menu item --- the 'buisness' scripts, for dealing with all button clicks +-- HANDLERS FOR BUTTON CLICKS + on clicked theObject -- MAIN WINDOW - Select File button if theObject is the button "selectButton" of window "MacGPSBabel" then @@ -108,6 +181,20 @@ on clicked theObject my showFilters() end if + -- MAIN WINDOW - Set As Defaults Button + if theObject is button "defaultsButton" of window "MacGPSBabel" then + set newInputIndex to contents of popup button "inPop" of window "MacGPSBabel" + set newOutputIndex to contents of popup button "outPop" of window "MacGPSBabel" + set newINstate to state of button "GPSswitchIN" of window "MacGPSBabel" as boolean + set newOUTstate to state of button "GPSswitchOUT" of window "MacGPSBabel" as boolean + tell user defaults + set contents of default entry "theInputType" to newInputIndex + set contents of default entry "theOutputType" to newOutputIndex + set contents of default entry "gpsIN" to newINstate + set contents of default entry "gpsOUT" to newOUTstate + end tell + end if + -- GPS Receiver Window - Continue button if theObject is the button "contButton" of window "SelectGPS" then if the state of button "GPSswitchIN" of window "MacGPSBabel" = 1 then @@ -177,24 +264,34 @@ on clicked theObject -- Filter Window - Arc filter check box if theObject is the button "arcSwitch" of window "filterWindow" then if state of button "arcSwitch" of window "filterWindow" is equal to 1 then - set fFile to choose file with prompt "Select an arc filter file" + try + set fFile to choose file with prompt "Select an arc filter file" + on error + set state of button "arcSwitch" of window "filterWindow" to 0 + return 0 + end try set contents of text field "arcFile" of window "filterWindow" to POSIX path of fFile as string set enabled of text field "arcDist" of window "filterWindow" to true set editable of text field "arcDist" of window "filterWindow" to true set enabled of popup button "arcUnits" of window "filterWindow" to true else + set contents of text field "arcFile" of window "filterWindow" to "" + set contents of text field "arcDist" of window "filterWindow" to "" set enabled of text field "arcDist" of window "filterWindow" to false set editable of text field "arcDist" of window "filterWindow" to false set enabled of popup button "arcUnits" of window "filterWindow" to false - set contents of text field "arcFile" of window "filterWindow" to "" - set contents of text field "ardDist" of window "filterWindow" to "" end if end if -- Filter Window - polygon filter check box if theObject is the button "polySwitch" of window "filterWindow" then if state of button "polySwitch" of window "filterWindow" is equal to 1 then - set pFile to choose file with prompt "Select a polygon filter file" + try + set pFile to choose file with prompt "Select a polygon filter file" + on error + set state of button "polySwitch" of window "filterWindow" to 0 + return 0 + end try set contents of text field "polyFile" of window "filterWindow" to POSIX path of pFile as string else set contents of text field "polyFile" of window "filterWindow" to "" @@ -619,6 +716,100 @@ on clearFiles() set enabled of button "sendButton" of window "MacGPSBabel" to false set key equivalent of button "selectButton" of window "MacGPSBabel" to return set enabled of button "clearButton" of window "MacGPSBabel" to false - set the contents of popup button "inPop" of window "MacGPSBabel" to 0 - set the contents of popup button "outPop" of window "MacGPSBabel" to 0 -end clearFiles \ No newline at end of file + + -- reset controls to user defaults + -- read current user defaults and set window controls as needed + my readSettings() + + -- deal with changes to MacGPSBabel window needed if any of the GPS check boxes are checked by default + if state of button "GPSswitchIN" of window "MacGPSBabel" is equal to 1 then + my gpsIN() + end if + if state of button "GPSswitchOUT" of window "MacGPSBabel" is equal to 1 then + my gpsOUT() + end if +end clearFiles + + +-- read user defaults +on readSettings() + tell user defaults + set defaultInputIndex to contents of default entry "theInputType" as integer + set defaultOutputIndex to contents of default entry "theOutputType" as integer + set defaultgpsIN to contents of default entry "gpsIN" as boolean + set defaultgpsOUT to contents of default entry "gpsOUT" as boolean + end tell + -- call method "setObjectValue:" of object (popup button "inPop" of window "MacGPSBabel") with parameter defaultInputIndex + -- call method "synchronizeTitleAndSelectedItem" of object (popup button "inPop" of window "MacGPSBabel") + set contents of popup button "inPop" of window "MacGPSBabel" to defaultInputIndex + set contents of popup button "outPop" of window "MacGPSBabel" to defaultOutputIndex + set state of button "GPSswitchIN" of window "MacGPSBabel" to defaultgpsIN + set state of button "GPSswitchOUT" of window "MacGPSBabel" to defaultgpsOUT +end readSettings + +-- scripts for dealing with GPS checkboxes on MacGPSBabel window +on gpsIN() + if state of button "GPSswitchIN" of window "MacGPSBabel" = 1 then + set enabled of button "selectButton" of window "MacGPSBabel" to false + set enabled of button "clearButton" of window "MacGPSBabel" to false + set enabled of button "sendButton" of window "MacGPSBabel" to true + set contents of text field "inputFile" of window "MacGPSBabel" to "" + set enabled of text field "inputFile" of window "MacGPSBabel" to false + set enabled of popup button "inPop" of window "MacGPSBabel" to false + else + set enabled of button "selectButton" of window "MacGPSBabel" to true + set enabled of button "sendButton" of window "MacGPSBabel" to false + set enabled of text field "inputFile" of window "MacGPSBabel" to true + set enabled of popup button "inPop" of window "MacGPSBabel" to true + end if +end gpsIN +on gpsOUT() + if state of button "GPSswitchOUT" of window "MacGPSBabel" = 1 then + set enabled of popup button "outPop" of window "MacGPSBabel" to false + else + set enabled of popup button "outPop" of window "MacGPSBabel" to true + end if +end gpsOUT + +-- List Populating Handlers + +-- find the serial ports +on getSerial() + set myList to {} + set theScript to "cd /dev; ls | grep cu\\." + set scriptOut to (do shell script theScript) as string + set theCount to count of paragraphs in scriptOut + set i to 0 + set defaultDelimiters to AppleScript's text item delimiters + set AppleScript's text item delimiters to {"."} + repeat until i = theCount + set i to i + 1 + set theWords to the count of text items in paragraph i of scriptOut + set z to 2 + set the end of myList to (text items z thru theWords of paragraph i of scriptOut) as string + end repeat + set AppleScript's text item delimiters to defaultDelimiters + return myList +end getSerial + +-- handler (called at startup) to check with GPS Babel which file formats it can handle. Return the result as a list +on getFormats() + set myList to {} + set typeList to {} + set extList to {} + set thePath to POSIX path of (path to me) as string + set scriptOut to (do shell script quoted form of thePath & "Contents/Resources/gpsbabel -^1") as string + set theCount to count of paragraphs in scriptOut + set defaultDelimiters to AppleScript's text item delimiters + set AppleScript's text item delimiters to tab + repeat with i from 1 to theCount + set theLine to paragraph i of scriptOut + if (first text item of theLine) is equal to "file" then + set the end of typeList to the second text item of theLine + set the end of extList to the third text item of theLine + set the end of myList to the last text item of theLine + end if + end repeat + set AppleScript's text item delimiters to defaultDelimiters + return myList +end getFormats \ No newline at end of file diff --git a/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/jeremya.pbxuser b/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/jeremya.pbxuser index 4411a0c1c..3089df577 100644 --- a/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/jeremya.pbxuser +++ b/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/jeremya.pbxuser @@ -1,5 +1,13 @@ // !$*UTF8*$! { + 089C165DFE840E0CC02AAC07 = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {711, 428}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {711, 428}}"; + sepNavWindowFrame = "{{19, 183}, {750, 558}}"; + }; + }; 29B97313FDCFA39411CA2CEA = { activeBuildStyle = 4A9504CCFFE6A4B311CA0CBA; activeExecutable = DA206CF0015C4D9F03C91932; @@ -19,14 +27,54 @@ PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; PBXFileTableDataSourceColumnWidthsKey = ( 20, - 242, + 604, + 20, + 108, + 43, + 43, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + PBXFileDataSource_Target_ColumnID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXSymbolsDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXSymbolsDataSource_SymbolNameID; + PBXFileTableDataSourceColumnWidthsKey = ( + 16, + 132.8008, + 161.0356, + 138.2085, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXSymbolsDataSource_SymbolTypeIconID, + PBXSymbolsDataSource_SymbolNameID, + PBXSymbolsDataSource_SymbolTypeID, + PBXSymbolsDataSource_ReferenceNameID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.XCSCMDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, 20, - 48, + 226, + 20, + 40, 43, 43, 20, ); PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_SCM_ColumnID, PBXFileDataSource_FiletypeID, PBXFileDataSource_Filename_ColumnID, PBXFileDataSource_Built_ColumnID, @@ -36,7 +84,29 @@ PBXFileDataSource_Target_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 115952475; + PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 210, + 50, + 20, + 50, + 43, + 43, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXTargetDataSource_PrimaryAttribute, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + ); + }; + PBXPerProjectTemplateStateSaveDate = 116301737; PBXPrepackagedSmartGroups_v2 = ( { PBXTransientLocationAtTop = bottom; @@ -848,7 +918,11 @@ WindowLocation = "{4, 381}"; }, ); - PBXWorkspaceStateSaveDate = 115952475; + PBXWorkspaceStateSaveDate = 116301737; + }; + perUserProjectItems = { + 3F26E6CA06EE9FD000A5ACEA = 3F26E6CA06EE9FD000A5ACEA; + 3FC2F7C606EE9F8B002083D3 = 3FC2F7C606EE9F8B002083D3; }; sourceControlManager = 3F8AAF0806E7E5D400E74F19; userBuildSettings = { @@ -860,6 +934,16 @@ DA206CF0015C4D9F03C91932, ); }; + 3F26E6CA06EE9FD000A5ACEA = { + fRef = DA206CF3015C4E8B03C91932; + isa = PBXTextBookmark; + name = "MacGPSBabel.applescript: 815"; + rLen = 0; + rLoc = 34625; + rType = 0; + vrLen = 1394; + vrLoc = 14697; + }; 3F8AAF0806E7E5D400E74F19 = { fallbackIsa = XCSourceControlManager; isSCMEnabled = 0; @@ -882,6 +966,16 @@ wantsCodeCompletionTabCompletes = 1; wantsIndex = 1; }; + 3FC2F7C606EE9F8B002083D3 = { + fRef = DA206CF3015C4E8B03C91932; + isa = PBXTextBookmark; + name = "MacGPSBabel.applescript: 815"; + rLen = 0; + rLoc = 34625; + rType = 0; + vrLen = 1409; + vrLoc = 14697; + }; DA206CF0015C4D9F03C91932 = { activeArgIndex = 2147483647; activeArgIndices = ( @@ -909,16 +1003,9 @@ }; DA206CF3015C4E8B03C91932 = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1672, 9810}}"; - sepNavSelRange = "{1155, 0}"; - sepNavVisRect = "{{0, 150}, {1109, 616}}"; - }; - }; - F586ED0005CB576C017C67C1 = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {983, 2250}}"; - sepNavSelRange = "{1520, 0}"; - sepNavVisRect = "{{0, 336}, {653, 184}}"; + sepNavIntBoundsRect = "{{0, 0}, {1672, 12225}}"; + sepNavSelRange = "{34625, 0}"; + sepNavVisRect = "{{0, 4905}, {862, 533}}"; }; }; } diff --git a/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/project.pbxproj b/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/project.pbxproj index 931dfc457..c2d2aad14 100644 --- a/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/project.pbxproj +++ b/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/project.pbxproj @@ -5,16 +5,9 @@ }; objectVersion = 39; objects = { - 080E96DCFE201CFB7F000001 = { - fileRef = 29B97318FDCFA39411CA2CEA; - isa = PBXBuildFile; - settings = { - }; - }; 080E96DDFE201D6D7F000001 = { children = ( DA206CF3015C4E8B03C91932, - F586ED0005CB576C017C67C1, ); isa = PBXGroup; name = Scripts; @@ -185,7 +178,7 @@ }; 29B97317FDCFA39411CA2CEA = { children = ( - 29B97318FDCFA39411CA2CEA, + 29B97319FDCFA39411CA2CEA, 089C165CFE840E0CC02AAC07, DA206CF4015C4E8B03C91932, F52E6CB4059959B801A80064, @@ -197,21 +190,10 @@ refType = 4; sourceTree = ""; }; - 29B97318FDCFA39411CA2CEA = { - children = ( - 29B97319FDCFA39411CA2CEA, - ); - isa = PBXVariantGroup; - name = MainMenu.nib; - path = ""; - refType = 4; - sourceTree = ""; - }; 29B97319FDCFA39411CA2CEA = { isa = PBXFileReference; lastKnownFileType = wrapper.nib; - name = English; - path = English.lproj/MainMenu.nib; + path = MainMenu.nib; refType = 4; sourceTree = ""; }; @@ -288,7 +270,7 @@ CFBundleSignature mGPS CFBundleVersion - 1.0.5 + 1.0.6 NSAppleScriptEnabled YES NSMainNibFile @@ -309,7 +291,7 @@ 29B97328FDCFA39411CA2CEA = { buildActionMask = 2147483647; files = ( - 080E96DCFE201CFB7F000001, + 3FC2F7BD06EE9EDE002083D3, 089C165EFE840E0CC02AAC07, F52E6CB5059959B801A80064, F514A08E05A6164F01A80064, @@ -347,6 +329,22 @@ //292 //293 //294 +//3F0 +//3F1 +//3F2 +//3F3 +//3F4 + 3FC2F7BD06EE9EDE002083D3 = { + fileRef = 29B97319FDCFA39411CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; +//3F0 +//3F1 +//3F2 +//3F3 +//3F4 //4A0 //4A1 //4A2 @@ -400,9 +398,9 @@ }; }; DA206CF3015C4E8B03C91932 = { + explicitFileType = sourcecode.applescript; fileEncoding = 30; isa = PBXFileReference; - lastKnownFileType = sourcecode.applescript; path = MacGPSBabel.applescript; refType = 4; sourceTree = ""; @@ -429,7 +427,6 @@ contextName = ""; files = ( DA206CF5015C4E8B03C91932, - F586ED0105CB576C017C67C1, ); isSharedContext = 0; isa = PBXAppleScriptBuildPhase; @@ -478,23 +475,6 @@ settings = { }; }; - F586ED0005CB576C017C67C1 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.applescript; - path = preferences.applescript; - refType = 4; - sourceTree = ""; - }; - F586ED0105CB576C017C67C1 = { - fileRef = F586ED0005CB576C017C67C1; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - Debug, - ); - }; - }; }; rootObject = 29B97313FDCFA39411CA2CEA; } -- 2.30.2